<template>
	<div id="employment-school">
		<div class="select" @click=select($event)>
			<base-areas></base-areas>
			<base-categorys v-if="otype=='a'"></base-categorys>
			<base-condition v-if="otype=='a'" @change=change></base-condition>
		</div>
		<base-schoollist :schools="otype=='a'?schools:job_schools"></base-schoollist>
		<div class='page' @click=opage($event)>
			<a href='#top' :class={school:show}>上一页</a>
			<a href='#top' value='+' :class={school:show}>下一页</a>
		</div>
	</div>
</template>
<script>
	module['recommond-chooseSchool'] = {
	props: ['logo', 'show', 'no_data', 'type', 'otype'],
	template: template,
	components: {
		'base-areas': require('base-areas'),
		'base-categorys': require('base-categorys'),
		'base-condition': require('base-condition'),
		'base-schoollist': require('base-schoollist')
	},
	data: function data() {
		return {
			schools: null,
			job_schools: null,
			school_opt: {
				page: 1
			},
			current_schools: null,
			current_job_schools: null,
			job_opt: {}
		};
	},
	created: function created() {
		var that = this;
		if (this.otype == 'a') {
			//按分推荐大学的时候
			base.request(base.api(65), {}, function (d) {
				that.schools = d.data;
				that.current_schools = { 1: d.data };
			});
		} else {
			//看就业选学校的时候
			base.request(base.api(35), {}, function (d) {
				that.job_schools = d.data;
				that.current_job_schools = { 1: that.job_schools };
			});
		}
	},
	methods: {
		select: function select(e) {
			base.select.call(this, e);
		},
		opage: function opage(e) {
			base.page.call(this, e);
		},
		change: function change(e) {
			var _this = this;
			if (_this.otype == 'a') {
				var url = base.api(65),
				    tar = e.target;
				_this.school_opt.page = 1;
				_this.current_schools = [];
				_this.school_opt[tar.getAttribute('type')] = $(tar).children().eq(tar.selectedIndex).attr('datavalue');
				base.request(url, _this.school_opt, function (d) {
					_this.no_data_score = d.data.length == 0;
					_this.current_schools = { 1: d.data };
					_this.schools = d.data;
				});
			}
		}
	}
};
</script>
